<script src="/include/calendar/calendar.js"></script>
<style type="text/css">
#search-form input,#search-form select {
	width: 128px;
}
</style>
<div class="pageheader">
	<h2>
		<i class="fa fa-pencil-square"></i>日志管理
	</h2>
	<div class="breadcrumb-wrapper">
		<span class="label">你所在的位置：</span>
		<ol class="breadcrumb">
			<li><a href="/index">ERP管理系统</a></li>
			<li>日志管理</li>
			<li class="active">打包日志</li>
		</ol>
	</div>
</div>
<div class="contentpanel">
<div class="main">
    <form id="search-form" class="form-inline" method="post" action="/log/packlog" style="margin-bottom: 10px;">
        <div class="form-group">
            <!-- <label for="Orderid">订单号</label>-->
            <input type="text" name="orderid" value="<?php echo $this->orderid;?>" class="form-control" placeholder="订单号">
        </div>
        <div class="form-group">
            <!-- <label for="Sku">运单号</label> -->
            <input type="text" name="billid" value="<?php echo $this->billid;?>" class="form-control" placeholder="运单号">
        </div>
        <div class="form-group">
            <!-- <label for="Site">网站</label> -->
            <select class='form-control' name='site'>
                <option value='' <?php if($this->site == ''){echo 'selected="selected"';}?>>选择网站</option>
                <option value='gogoalshop.com' <?php if($this->site == 'gogoalshop.com'){echo 'selected="selected"';}?>>gogoalshop.com</option>
		        <option value='minejerseys.com' <?php if($this->site == 'minejerseys.com'){echo 'selected="selected"';}?>>minejerseys.com</option>
		        <option value='jerseysmark.com' <?php if($this->site == 'jerseysmark.com'){echo 'selected="selected"';}?>>jerseysmark.com</option>
		        <option value='goaljerseys.com' <?php if($this->site == 'goaljerseys.com'){echo 'selected="selected"';}?>>goaljerseys.com</option>
		        <option value='fancybestdeal.com' <?php if($this->site == 'fancybestdeal.com'){echo 'selected="selected"';}?>>fancybestdeal.com</option>
	    	    <option value='elmontyouthsoccer.com' <?php if($this->site == 'elmontyouthsoccer.com'){echo 'selected="selected"';}?>>elmontyouthsoccer.com</option>
		        <option value='bestcheapsoccer.com' <?php if($this->site == 'bestcheapsoccer.com'){echo 'selected="selected"';}?>>bestcheapsoccer.com</option>
	    	</select>
        </div>
        <div class="form-group">
            <label for="date">日期:</label>
            <input class="form-control" type="text" name="starttime" onclick="new Calendar().show(this);" readonly="readonly" value="<?php echo $this->starttime;?>">
	               至<input class="form-control" type="text" name="endtime" onclick="new Calendar().show(this);" readonly="readonly" value="<?php echo $this->endtime;?>">
        </div>
        <button type="submit" class="btn btn-primary">搜索</button>
    </form>
    <div class="table-responsive">
        <?php if(!empty($this->logList)){?>
        <table id="pack-log" class="table table-bordered table-hover">
            <thead>
                <tr class="info">
                    <th>网站订单号</th>
                    <th>快递单号</th>
                    <th>包裹内容</th>
                    <th>打包员</th>
                    <th>打包时间</th>
                </tr>
            </thead>
            <tbody>
            <?php 
                if ($this->logList){
                	foreach ($this->logList as $v){
                ?>
                <tr>
                    <td><a target="_blank" href="<?php echo $this->url(array('controller'=>'log','action'=>'index','oid' =>$v['order_id'],'site'=>$v['site']),null,true); ?>"><?php echo $v['order_id'].'<br/>'.$v['site'];?></a></td>
                    <td><?php echo $v['bill_id'];?></td>
                    <td>
                        <table class="table table-bordered table-hover">
                            <thead><tr><th>SKU</th><th>名称</th><th>尺码数量</th><th>赠品</th><th>分拣员</th><th>分拣时间</th><th>操作员</th><th>操作时间</th><th>状态</th></tr></thead>
                            <tbody>
                            <?php
                            $sort_ids = json_decode($v['sort_ids']);
                            foreach ($sort_ids as $sid){
                            	$sortlog = App_Model::factory('OrderSortLog');//订单分拣日志表
                            	$vv = $sortlog->getById(intval($sid));
                            ?>
                                <tr><td><?php echo $vv['sku'];?></td>
                                <td><?php echo $vv['title'];?></td>
                                <td><?php echo '尺码: ' . $vv['size'] . ', 数量: 1 <br/>'; ?></td>
				                <td><?php if($vv['isgift']){echo '是';}else{echo '否';}?></td>
				                <td><?php echo $vv['adduser']; ?></td>
				                <td><?php echo $vv['add_time']; ?></td>
				                <td><?php if(empty($vv['operuser'])){echo '无操作';}else{echo $vv['operuser'];} ?></td>
				                <td><?php if(empty($vv['oper_time'])){echo '无操作';}else{echo $vv['oper_time'];} ?></td>
				                <td>
				                <?php
				                    switch ($vv['statu'])
				                    {
				        	            case 1:
				        		            echo '<span class="status label label-primary">已操作、未打包</span>';
				        		            break;
				        	            case 2:
				        		            echo '<span class="status label label-success">已打包</span>';
				        		            break;
				        	            default:
				        		            echo '<span class="status label label-warning">未处理</span>';
				                    }
				                ?>
				                </td></tr>
                            <?php
                            }
                            ?></tbody>
                        </table>
                    </td>
				    <td><?php echo $v['adduser']; ?></td>
				    <td><?php echo $v['add_time']; ?></td>
			    </tr>
			    <?php
                	}
                }
			    ?>
			    <tr>
			        <td colspan="5">
			        <?php
					     echo $this->paginationControl ( $this->paginator, 'Sliding', 'page/pager.phtml', array (
					     	'billid'=>$this->orderid,
					     	'orderid'=>$this->orderid,
					     	'site'=>$this->site,
						    'starttime' => $this->starttime,
						    'endtime' => $this->endtime 
				    	) );
				    ?>
			        </td>
			    </tr>
            </tbody>
        </table>
        <?php }?>
    </div>
</div>
</div>
